//
//  XLSwitchUserCell.m
//  industry
//
//  Created by xl on 2020/12/17.
//  Copyright © 2020 Haier. All rights reserved.
//

#import "XLSwitchUserCell.h"
#import "XLSwitchUserModel.h"

@interface XLSwitchUserCell ()

@property (nonatomic, strong) XLView *bgView;
@property (nonatomic, strong) XLImageView *iconIG;
@property (nonatomic, strong) XLLabel *titleLB;
@property (nonatomic, strong) XLImageView *arrowIG;

@end
@implementation XLSwitchUserCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor whiteBgColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;

        [self.contentView addSubview:self.bgView];
        [_bgView addSubview:self.iconIG];
        [_bgView addSubview:self.titleLB];
        [_bgView addSubview:self.arrowIG];
        
        [self makeConstraints];
    }
    return self;
}

- (void)makeConstraints {
    [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(20);
        make.right.equalTo(self.contentView).offset(-20);
        make.top.bottom.equalTo(self.contentView);
    }];
    
    [_iconIG mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bgView).offset(20);
        make.centerY.equalTo(self.bgView);
        make.size.mas_equalTo(CGSizeMake(30, 30));
    }];
    
    [_titleLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconIG.mas_right).offset(20);
        make.centerY.equalTo(self.bgView);
    }];
    [_arrowIG mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.bgView).offset(-20);
        make.centerY.equalTo(self.bgView);
        make.size.mas_equalTo(CGSizeMake(10, 18));
    }];
}

#pragma mark - Public
- (void)loadCellData:(XLSwitchUserModel *)model {
    _titleLB.text = model.cusName;
}

#pragma mark - Setter/getter
- (XLView *)bgView {
    if (!_bgView) {
        _bgView = [XLView new];
        _bgView.backgroundColor = [UIColor whiteColor];
        _bgView.layer.cornerRadius = 20.0f;
        _bgView.layer.shadowColor = [UIColor colorWithHex:0x000000 alpha:0.08].CGColor;
        _bgView.layer.shadowOffset = CGSizeMake(0,-6);
        _bgView.layer.shadowOpacity = 1;
        _bgView.layer.shadowRadius = 20;
    }
    return _bgView;
}

- (XLImageView *)iconIG {
    if (!_iconIG) {
        _iconIG = [XLImageView new];
        _iconIG.image = XLIMAGE(@"jsicon");
    }
    return _iconIG;
}

- (XLLabel *)titleLB {
    if (!_titleLB) {
        _titleLB = [XLLabel new];
        _titleLB.font = [UIFont fontOfPingFangSCSemiboldWithSize:13];
        _titleLB.textColor = [UIColor blackFontColor];
    }
    return _titleLB;
}

- (XLImageView *)arrowIG {
    if (!_arrowIG) {
        _arrowIG = [XLImageView new];
        _arrowIG.image = XLIMAGE(@"hsjt");
    }
    return _arrowIG;
}

@end
